<template>
  <el-container class="home-container">
    <el-aside width="auto">
      <el-menu class="el-menu-vertical" default-active="/main" router text-color="#b8c7ce" background-color="#222d32"
               @open="handleOpen"
               @close="handleClose"
               :collapse="isCollapse">
        <el-menu-item index="/home">
          <i class="el-icon-s-home"></i>
          <span slot="title">系统首页</span>
        </el-menu-item>
        <el-menu-item index="/notificationManagement">
          <i class="el-icon-monitor"></i>
          <span slot="title">通知管理</span>
        </el-menu-item>
        <el-menu-item index="/record">
          <i class="el-icon-edit-outline"></i>
          <span slot="title">人员打卡总记录</span>
        </el-menu-item>
        <el-menu-item index="/reportManagement">
          <i class="el-icon-document"></i>
          <span slot="title">人员报备总记录</span>
        </el-menu-item>
        <el-submenu index="5">
          <template slot="title">
            <i class="el-icon-setting"></i>
            <span slot="title">系统用户管理</span>
          </template>
          <el-menu-item index="/userManagement">
            <i class="el-icon-s-data"></i>
            <span>用户管理</span>
          </el-menu-item>
        </el-submenu>
        <el-submenu index="6">
          <template slot="title">
            <i class="el-icon-user"></i>
            <span slot="title">疫情人员管理</span>
          </template>
          <el-menu-item index="/touchManagement">
            <i class="el-icon-s-data"></i>
            <span>密切接触者管理</span>
          </el-menu-item>
          <el-menu-item index="/patientManagement">
            <i class="el-icon-s-data"></i>
            <span>确诊患者管理</span>
          </el-menu-item>
          <el-menu-item index="/deathManagement">
            <i class="el-icon-s-data"></i>
            <span>死亡病例管理</span>
          </el-menu-item>
          <el-menu-item index="/cureManagement">
            <i class="el-icon-s-data"></i>
            <span>治愈管理</span>
          </el-menu-item>
        </el-submenu>

      </el-menu>
    </el-aside>

    <el-container>
      <el-header class="home-header" height="56px">
        <i :class="isCollapse?'el-icon-s-unfold':'el-icon-s-fold'" class="fold-icon"
           @click="isCollapse=!isCollapse"></i>
        <div>管理系统</div>
        <div class="admin-info">
          <el-dropdown>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>查看信息</el-dropdown-item>
              <div @click="quit">
                <el-dropdown-item>退出</el-dropdown-item>
              </div>
            </el-dropdown-menu>
          </el-dropdown>
          <span>当前登陆用户:&nbsp;&nbsp;&nbsp;<span class="username">{{ user.name }}</span></span>
        </div>

      </el-header>
      <div class="box-breadcrumb">
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item v-for="item in []"
                              :key="item.path"
                              :to="item.path">{{ item.meta.tittle }}
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>

      <el-main class="home-main">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>

</template>

<script>
import {getUserInfo, quit} from "@/api/user";
import router from "@/routers";

export default {
  name: "HomePage",
  data() {
    return {
      isCollapse: false,
      user: {}
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    quit() {
      console.log("退出")
      quit().then(res => {
        this.$message.success("登出成功");
        router.push("/login")
        // location.reload()// 为了重新实例化vue-router对象 避免bug
      })
    },
  },
  mounted() {
    getUserInfo().then(res => {
      console.log(res)
      this.user = res.data;
    });
  }
}
</script>

<style scoped>

.home-container {
  width: 100vw;
  height: 100vh;
  min-width: 1200px;
}

.home-main {
  background-color: #f5f5f5;
  color: #333;
  padding: 0;
}

.el-header {
  background-color: #3c8dbc;
  color: #ffffff;
  padding: 0;
  /*text-align: center;*/
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.el-aside {
  background-color: #222d32;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-menu {
  border-right: 0;
}

.el-menu-vertical:not(.el-menu--collapse) {
  width: 200px;
  height: 100vh;
}

.el-menu--collapse {
  height: 100vh;
}

.fold-icon {
  font-size: 25px;
  margin-left: 10px;
  display: flex;
}

.admin-info {
  display: flex;
  align-items: center;
  margin-right: 30px;
}

.box-breadcrumb {
  font-size: 18px;
  background-color: #E9EEF3;
  padding: 23px;
}

.el-breadcrumb-item {
  margin-top: 10px;
}

.username{
  /*font-size: 30px;*/
  color: aquamarine;
}
</style>
